package com.design;

import java.awt.Checkbox;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Random;

import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;

import com.database.LoginDb;
import com.database.RegistrationDatabase;
import com.database.RegistrationVO;
import com.receive.ClientRecv;
import com.request.ClientRequest;

public class Layers extends JFrame implements MouseListener, ActionListener {
	public JPanel jpanel;

	public JRadioButton balAval;

	public JRadioButton laTran;

	public JRadioButton chqSts;

	public JRadioButton dchSts;

	public JRadioButton chgPin;

	JButton registerJButton;

	public JButton jButtonReqButton;

	public JButton jButtonSubscribe;

	public JButton jButtonSearch;

	public JButton jButtonUnsubscribe;

	private JButton chequeJButton;

	public JButton jButtonMobile;

	JTextField jTextFieldSearchAct = new JTextField();

	JTextField jTextFieldChequeFrom = new JTextField();

	JTextField jTextFieldChequeTo = new JTextField();

	JTextField jTextFieldSearchAmt = new JTextField();

	JTextField chequeJTextFieldAccount;

	JTextField chequejTextFieldChequeNum;

	JTextField chequeJTextFieldAmount;

	JTextField chequeJTextFieldDate;

	public ButtonGroup buttonGroup;

	JTextField regjTextFieldAct;

	public static JTextArea jTextAreaRequest;

	JTextField regjTextFieldCus;

	JTextField regjTextFieldBal;

	JPasswordField jpassWord;

	JTextField regjTextFieldEmail;

	public JLabel jLabelSearchAmt = new JLabel();

	public static JButton jButtonCal;

	public static JFrame f = new JFrame("Calendar");

	private JButton paymentsJButton;

	public static JTextField jTextFieldAccountDate;

	private JTextField jTextFieldCusName;

	private JTextField loginUser;

	private JPasswordField loginPass;

	private JButton loginJbutton;

	JLabel jLabelImage;

	private JButton jButton;

	JComboBox jComboBox = new JComboBox();

	public JTextField paymentsaccountNoTextField;

	public JComboBox jComboBoxCity = new JComboBox();

	public JTextField paymentsAmountTextField;

	JButton jButtonTransfer = new JButton();

	JLabel jLabelCheque;

	public JTextField jTextFieldBillerName;

	JTextField jTextFieldTos = new JTextField();

	JTextField jTextFieldAmount = new JTextField();

	public JTextField RegisterjTextFieldAccountNo;

	JLabel jLabelSearchAcct = new JLabel();

	public JTextField RegisterjTextFieldMobileNumber;

	private Validation validation = new Validation();

	private ClientRequest clientRequest = new ClientRequest();

	public static DefaultTableModel routerTab = new DefaultTableModel();

	public static DefaultTableModel mtab = new DefaultTableModel();

	private String radioText = "";

	public JPanel SmsBanking(JPanel pp) {
		JScrollPane jScrollPane = new JScrollPane(
				JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
				JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		// jpanel = new JPanel();
		jpanel = pp;
		// jpanel.setLayout(null);
		// jpanel.setBounds(0,130,800,450);
		JLabel jLabelTitle = new JLabel("Sms Banking");
		balAval = new JRadioButton("BalAval", true);

		laTran = new JRadioButton("LaTran");
		chqSts = new JRadioButton("ChqSts");
		dchSts = new JRadioButton("DchSts");
		chgPin = new JRadioButton("ChgPin");
		buttonGroup = new ButtonGroup();

		buttonGroup.add(balAval);
		buttonGroup.add(laTran);
		buttonGroup.add(chqSts);
		buttonGroup.add(dchSts);
		buttonGroup.add(chgPin);
		balAval.setBounds(150, 60, 150, 20);
		laTran.setBounds(150, 90, 150, 20);
		chqSts.setBounds(150, 120, 150, 20);
		dchSts.setBounds(150, 150, 150, 20);
		chgPin.setBounds(150, 180, 150, 20);

		jTextAreaRequest = new JTextArea(10, 50);
		// jScrollPane.add(jTextAreaRequest);
		jTextAreaRequest.setBounds(400, 60, 300, 150);
		jTextAreaRequest.setEditable(false);
		jButtonReqButton = new JButton("Request");
		jButtonReqButton.setBounds(350, 250, 90, 30);
		jButtonReqButton.addActionListener(this);
		jButtonSubscribe = new JButton("Subscribe");
		jButtonSubscribe.setBounds(490, 250, 110, 30);

		jButtonUnsubscribe = new JButton("UnSubscribe");
		jButtonUnsubscribe.setBounds(650, 250, 110, 30);
		jLabelTitle.setBounds(350, 10, 200, 30);
		jpanel.add(jLabelTitle);
		jpanel.add(jButtonReqButton);
		jButtonSubscribe.addActionListener(this);
		jButtonUnsubscribe.addActionListener(this);
		jpanel.add(jButtonSubscribe);
		jpanel.add(jButtonUnsubscribe);
		jpanel.add(jTextAreaRequest);
		balAval.addActionListener(this);
		laTran.addActionListener(this);
		chqSts.addActionListener(this);
		dchSts.addActionListener(this);
		chgPin.addActionListener(this);
		jpanel.add(balAval);
		jpanel.add(laTran);
		jpanel.add(chqSts);
		jpanel.add(dchSts);
		jpanel.add(chgPin);

		return jpanel;
	}

	public JPanel PaymentsViews(JPanel pp) {
		JPanel jPanel = pp;

		jComboBox.addItem("Airtel");
		jComboBox.addItem("Aircel");
		jComboBox.addItem("Vodafone");
		JLabel jLabelTitle = new JLabel("Bill Payment");
		paymentsJButton = new JButton("Pay Bills");
		paymentsaccountNoTextField = new JTextField();
		paymentsAmountTextField = new JTextField();
		// jPanel.setLayout(null);
		JLabel biller = new JLabel("Biller");
		JLabel accountNo = new JLabel("AccountNo");
		JLabel amount = new JLabel("Amount");
		biller.setBounds(300, 100, 60, 30);
		accountNo.setBounds(450, 100, 100, 30);
		amount.setBounds(600, 100, 60, 30);
		jComboBox.setBounds(300, 150, 100, 30);
		paymentsaccountNoTextField.setBounds(450, 150, 100, 30);
		paymentsAmountTextField.setBounds(600, 150, 100, 30);
		paymentsJButton.setBounds(450, 250, 100, 30);
		jLabelTitle.setBounds(350, 10, 200, 30);
		jPanel.add(jLabelTitle);
		paymentsJButton.addActionListener(this);
		jPanel.add(paymentsJButton);
		jPanel.add(jComboBox);
		jPanel.add(paymentsaccountNoTextField);
		jPanel.add(paymentsAmountTextField);
		jPanel.add(biller);
		jPanel.add(accountNo);
		jPanel.add(amount);
		return jPanel;
	}

	public JPanel RegisterBillPayement(JPanel jP) {
		JPanel jPanel = jP;
		// jPanel.setLayout(null);
		JLabel jLabelTitle = new JLabel("Registering Bill Payment");
		JLabel jLabelCity = new JLabel("City");
		JLabel jLabelBillerName = new JLabel("BillerName");
		JLabel jLabelAccountNo = new JLabel("Account Number");
		JLabel jLabelMobileNumber = new JLabel("MobileNumber");
		JLabel jLabelCusName = new JLabel("CustomerName");

		jButton = new JButton("Register");
		jTextFieldBillerName = new JTextField();
		RegisterjTextFieldAccountNo = new JTextField();
		RegisterjTextFieldMobileNumber = new JTextField();
		jTextFieldCusName = new JTextField();
		jLabelCity.setBounds(300, 70, 100, 30);
		jLabelBillerName.setBounds(300, 120, 100, 30);
		jLabelAccountNo.setBounds(300, 170, 100, 30);
		jLabelMobileNumber.setBounds(300, 220, 100, 30);
		jLabelCusName.setBounds(300, 270, 100, 30);

		jComboBoxCity.addItem("Chennai");
		jComboBoxCity.addItem("Vellore");
		jComboBoxCity.addItem("Madurai");
		jComboBoxCity.addItem("Trichy");

		jComboBoxCity.setBounds(450, 70, 100, 30);
		jTextFieldBillerName.setBounds(450, 120, 100, 30);
		RegisterjTextFieldAccountNo.setBounds(450, 170, 100, 30);
		RegisterjTextFieldMobileNumber.setBounds(450, 220, 100, 30);
		jTextFieldCusName.setBounds(450, 270, 100, 30);
		jButton.setBounds(450, 330, 100, 30);
		jLabelTitle.setBounds(350, 10, 200, 30);
		jPanel.add(jLabelTitle);
		jButton.addActionListener(this);
		jPanel.add(jButton);
		jPanel.add(jTextFieldBillerName);

		jPanel.add(RegisterjTextFieldAccountNo);
		jPanel.add(RegisterjTextFieldMobileNumber);
		jPanel.add(jTextFieldCusName);
		jPanel.add(jLabelBillerName);
		jPanel.add(jComboBoxCity);
		jPanel.add(jLabelAccountNo);
		jPanel.add(jLabelMobileNumber);
		jPanel.add(jLabelCusName);
		jPanel.add(jLabelCity);

		return jPanel;
	}

	public JPanel ChequePayments(JPanel jP) {
		JPanel jPanel = jP;
		ImageIcon myIcon = new ImageIcon("images/cal.jpg");
		// jPanel.setLayout(null);
		jLabelCheque = new JLabel(myIcon);
		JLabel jLabelTitle = new JLabel("Cheque Transfers");
		JLabel jLabelFrom = new JLabel("Account No");
		JLabel jLabelTos = new JLabel("Cheque No");
		JLabel jLabelAmount = new JLabel("Amount");
		// JLabel jLabelDate = new JLabel("Date");
		chequeJTextFieldAccount = new JTextField();
		chequejTextFieldChequeNum = new JTextField();
		chequeJTextFieldAmount = new JTextField();
		jTextFieldAccountDate = new JTextField();
		jLabelFrom.setBounds(300, 70, 100, 30);
		jLabelTos.setBounds(300, 120, 100, 30);
		jLabelAmount.setBounds(300, 170, 100, 30);
		// jLabelDate.setBounds(300, 220, 100, 30);
		chequeJButton = new JButton("Pay");
		chequeJButton.setBounds(450, 250, 100, 30);
		chequeJButton.addActionListener(this);
		chequeJTextFieldAccount.setBounds(450, 70, 100, 30);
		chequejTextFieldChequeNum.setBounds(450, 120, 100, 30);
		chequeJTextFieldAmount.setBounds(450, 170, 100, 30);
		jTextFieldAccountDate.setBounds(450, 220, 100, 30);
		// jLabelCheque.addMouseListener(this);
		jLabelCheque.setBounds(550, 220, 100, 30);
		jLabelTitle.setBounds(350, 10, 200, 30);
		jPanel.add(jLabelTitle);
		jPanel.add(jLabelCheque);
		jPanel.add(jLabelFrom);
		jPanel.add(jLabelTos);
		jPanel.add(jLabelAmount);
		// jPanel.add(jLabelDate);
		jPanel.add(chequeJButton);
		jPanel.add(chequeJTextFieldAccount);
		jPanel.add(chequejTextFieldChequeNum);
		jPanel.add(chequeJTextFieldAmount);
		// jPanel.add(jTextFieldAccountDate);

		return jPanel;
	}

	public JPanel AccountsTransfer(JPanel jP) {
		JPanel jPanel = jP;
		ImageIcon myIcon = new ImageIcon("images/cal.jpg");
		// jPanel.setLayout(null);
		jLabelImage = new JLabel(myIcon);
		JLabel jLabelTitle = new JLabel("Own Account Transfer");
		// JLabel jLabelFrom = new JLabel("Account From");
		JLabel jLabelTos = new JLabel("Account To");
		JLabel jLabelAmount = new JLabel("Amount");
		// JLabel jLabelDate = new JLabel("Date");
		// JTextField jTextFieldFrom = new JTextField();

		jTextFieldAccountDate = new JTextField();
		// jLabelFrom.setBounds(300, 70, 100, 30);
		jLabelTos.setBounds(300, 120, 100, 30);
		jLabelAmount.setBounds(300, 170, 100, 30);
		// jLabelDate.setBounds(300, 220, 100, 30);
		jButtonTransfer = new JButton("Transfer");
		jButtonTransfer.setBounds(400, 250, 100, 30);
		jButtonTransfer.addActionListener(this);
		// jLabelImage.addMouseListener(this);
		// jTextFieldFrom.setBounds(450, 70, 100, 30);
		jTextFieldTos.setBounds(450, 120, 100, 30);
		jTextFieldAmount.setBounds(450, 170, 100, 30);
		jTextFieldAccountDate.setBounds(450, 220, 100, 30);
		jLabelImage.setBounds(550, 220, 100, 30);
		jLabelTitle.setBounds(350, 10, 200, 30);
		jPanel.add(jLabelTitle);
		jPanel.add(jLabelImage);
		// jPanel.add(jLabelFrom);
		jPanel.add(jLabelTos);
		jPanel.add(jLabelAmount);
		// jPanel.add(jLabelDate);
		jPanel.add(jButtonTransfer);
		// jPanel.add(jTextFieldFrom);
		jPanel.add(jTextFieldTos);
		jPanel.add(jTextFieldAmount);
		// jPanel.add(jTextFieldAccountDate);

		return jPanel;
	}

	public JPanel ThridPartyTraansfer(JPanel jP) {
		JPanel jPanel = jP;
		JComboBox jComboBox = new JComboBox();
		JLabel jLabelTitle = new JLabel("Third Party Transfer");
		JButton jButton = new JButton("Transfer");
		JTextField accountNoTextField = new JTextField();
		JTextField amountTextField = new JTextField();
		// jPanel.setLayout(null);
		JLabel payee = new JLabel("Payee Type");
		JLabel PayeeName = new JLabel("Payee Name");
		JLabel AccountNumber = new JLabel("Account Number");
		payee.setBounds(300, 100, 100, 30);
		PayeeName.setBounds(450, 100, 100, 30);
		AccountNumber.setBounds(600, 100, 100, 30);
		jComboBox.setBounds(300, 150, 100, 30);
		accountNoTextField.setBounds(450, 150, 100, 30);
		amountTextField.setBounds(600, 150, 100, 30);
		jButton.setBounds(450, 250, 100, 30);
		jLabelTitle.setBounds(350, 10, 200, 30);
		jPanel.add(jLabelTitle);
		jPanel.add(jButton);
		jPanel.add(jComboBox);
		jPanel.add(accountNoTextField);
		jPanel.add(amountTextField);
		jPanel.add(payee);
		jPanel.add(PayeeName);
		jPanel.add(AccountNumber);
		return jPanel;

	}

	public JPanel chequeStatus(JPanel jP) {
		JPanel jPanel = jP;
		// jPanel.setLayout(null);
		JLabel jLabelTitle = new JLabel("Cheque Status");

		// JTextField jTextFieldDateFrom = new JTextField();
		// JTextField jTextFieldDateTo = new JTextField();

		jButtonSearch = new JButton("search");
		jLabelSearchAcct = new JLabel("AccountNo");
		JLabel jLabelChequeRange = new JLabel("Cheque No Range");
		// JLabel jLabelDate = new JLabel("Date Range");
		// JLabel jLabel = new JLabel("Amount");
		jLabelSearchAcct.setBounds(300, 70, 100, 30);
		jLabelChequeRange.setBounds(300, 120, 100, 30);
		// jLabelDate.setBounds(300, 170, 100, 30);
		// jLabel.setBounds(300, 170, 100, 30);
		jButtonSearch.addActionListener(this);
		jButtonSearch.setBounds(450, 200, 100, 30);
		jTextFieldSearchAct.setBounds(450, 70, 100, 30);
		jTextFieldChequeFrom.setBounds(450, 120, 100, 30);
		jTextFieldChequeTo.setBounds(590, 120, 100, 30);
		// jTextFieldDateFrom.setBounds(450, 170, 100, 30);
		// jTextFieldDateTo.setBounds(590, 170, 100, 30);
		// jTextFieldAmount.setBounds(450, 170, 100, 30);
		jLabelTitle.setBounds(350, 10, 200, 30);
		jPanel.add(jLabelTitle);
		jPanel.add(jButtonSearch);
		jPanel.add(jTextFieldSearchAct);
		jPanel.add(jTextFieldChequeFrom);
		jPanel.add(jTextFieldChequeTo);
		// jPanel.add(jTextFieldDateFrom);
		// jPanel.add(jTextFieldDateTo);
		// jPanel.add(jTextFieldAmount);
		jPanel.add(jButtonSearch);
		jPanel.add(jLabelSearchAcct);
		jPanel.add(jLabelChequeRange);
		// jPanel.add(jLabelDate);
		// jPanel.add(jLabel);

		return jPanel;
	}

	public JPanel Registration(JPanel jp) {
		JPanel jPanel = jp;
		JLabel jLabelTitle = new JLabel("Registration Form");
		JLabel cusName = new JLabel("Customer Name");
		JLabel accountNumber = new JLabel("Account Number");
		JLabel passWord = new JLabel("Password");
		// JLabel balance=new JLabel("Balance");
		JLabel email = new JLabel("Email Address");
		registerJButton = new JButton("Registration");
		registerJButton.setBounds(450, 350, 110, 30);
		regjTextFieldAct = new JTextField();
		regjTextFieldCus = new JTextField();
		jpassWord = new JPasswordField();
		// regjTextFieldBal= new JTextField();
		regjTextFieldEmail = new JTextField();
		regjTextFieldCus.setBounds(450, 70, 100, 30);
		regjTextFieldAct.setBounds(450, 120, 100, 30);
		// regjTextFieldBal.setBounds(450, 220, 100, 30);
		regjTextFieldEmail.setBounds(450, 220, 100, 30);
		jLabelTitle.setBounds(350, 10, 200, 30);
		cusName.setBounds(300, 70, 100, 30);
		accountNumber.setBounds(300, 120, 100, 30);
		passWord.setBounds(300, 170, 100, 30);
		// balance.setBounds(300, 220, 100, 30);
		email.setBounds(300, 220, 100, 30);
		jpassWord.setBounds(450, 170, 100, 30);
		registerJButton.addActionListener(this);
		jPanel.add(jpassWord);
		jPanel.add(regjTextFieldCus);
		jPanel.add(regjTextFieldAct);
		jPanel.add(cusName);
		jPanel.add(accountNumber);
		jPanel.add(passWord);
		jPanel.add(jLabelTitle);
		// jPanel.add(balance);
		// jPanel.add(regjTextFieldBal);
		jPanel.add(regjTextFieldEmail);
		jPanel.add(registerJButton);
		jPanel.add(email);
		return jPanel;
	}

	public JPanel Login(JPanel jP) {
		JPanel jPanel = jP;
		JLabel jLabelTitle = new JLabel("Login Form");
		JLabel jLabelUser = new JLabel("UserName");
		JLabel jLabelPassword = new JLabel("Password");
		loginUser = new JTextField();
		loginPass = new JPasswordField();
		loginJbutton = new JButton("Login");
		jLabelTitle.setBounds(350, 10, 200, 30);
		jLabelUser.setBounds(285, 120, 100, 30);
		jLabelPassword.setBounds(285, 170, 100, 30);
		loginUser.setBounds(385, 120, 100, 30);
		loginPass.setBounds(385, 170, 100, 30);
		loginJbutton.addActionListener(this);
		loginJbutton.setBounds(335, 230, 100, 30);
		jPanel.add(loginJbutton);
		jPanel.add(loginUser);
		jPanel.add(loginPass);
		jPanel.add(jLabelTitle);
		jPanel.add(jLabelUser);
		jPanel.add(jLabelPassword);
		return jPanel;
	}

	public JPanel RouterDesign(JPanel jP) {
		JPanel jPanel = jP;
		// JLabel jLabelTitle = new JLabel("Router Form");
		// jLabelTitle.setBounds(350, 10, 200, 30);
		// jPanel.add(jLabelTitle);

		JTable tab = new JTable(routerTab);
		// /routerTab.addColumn("S.No");
		// routerTab.addColumn("RequestNode");
		// routerTab.addColumn("RequestContent");
		// routerTab.addColumn("Status");
		routerTab.addColumn("Index");
		routerTab.addColumn("RequestSystem");
		routerTab.addColumn("RequestPort");
		routerTab.addColumn("Transmission Rate");
		routerTab.addColumn("ServertSystem");
		routerTab.addColumn("ServertPort");
		routerTab.addColumn("RequestItem");
		routerTab.addColumn("Status");
		JScrollPane stab = new JScrollPane(tab);
		stab.setBounds(20, 50, 950, 200);
		jPanel.add(stab);
		return jPanel;
	}

	public JPanel ServerDesign(JPanel jP) {
		JPanel jPanel = jP;

		JTable tab = new JTable(mtab);
		tab = new JTable(mtab);
		mtab.addColumn("Priority");
		mtab.addColumn("RequestSystem");
		mtab.addColumn("RequestPort");
		mtab.addColumn("Transmission Rate");
		mtab.addColumn("RouterSystem");
		mtab.addColumn("RouterPort");
		mtab.addColumn("RequestItem");
		JScrollPane stab = new JScrollPane(tab);
		stab = new JScrollPane(tab);
		stab.setBounds(20, 50, 950, 200);
		jPanel.add(stab);
		return jPanel;
	}

	public JPanel Estatement(JPanel jP) {
		JPanel jPanel = jP;
		JLabel jLabelTitle = new JLabel("Estatement");
		JCheckBox jCheckMail = new JCheckBox("Old Email-id");
		JCheckBox jCheckAccount = new JCheckBox("Account Details");
		JCheckBox jCheckCheque = new JCheckBox("Cheque Details");
		JButton jButton = new JButton("Submit");
		ButtonGroup buttonGroup = new ButtonGroup();
		buttonGroup.add(jCheckMail);
		buttonGroup.add(jCheckAccount);
		buttonGroup.add(jCheckCheque);
		jLabelTitle.setBounds(350, 10, 200, 30);
		jCheckMail.setBounds(300, 100, 150, 15);
		jCheckAccount.setBounds(300, 140, 150, 15);
		jCheckCheque.setBounds(300, 180, 150, 15);
		jButton.setBounds(300, 250, 100, 30);
		jButton.addActionListener(this);
		jPanel.add(jLabelTitle);
		jPanel.add(jCheckMail);
		jPanel.add(jCheckAccount);
		jPanel.add(jCheckCheque);
		jPanel.add(jButton);

		return jPanel;
	}

	public void mouseClicked(MouseEvent e) {
		Cal cal = new Cal();
		if (e.getSource() == jLabelImage || e.getSource() == jLabelCheque) {

			Container c = f.getContentPane();
			c.setLayout(new FlowLayout());
			c.add(cal);
			c.add(jButtonCal);
			f.pack();
			f.setVisible(true);

		}

	}

	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	public void actionPerformed(ActionEvent arg0) {
		if (arg0.getSource() == balAval) {
			radioText = balAval.getText();
		} else if (arg0.getSource() == laTran) {
			radioText = laTran.getText();

		} else if (arg0.getSource() == chqSts) {
			radioText = chqSts.getText();
		} else if (arg0.getSource() == dchSts) {
			radioText = dchSts.getText();
		} else if (arg0.getSource() == chgPin) {
			radioText = chgPin.getText();
		}

		if (arg0.getSource() == jButtonReqButton) {
			String pinTemp = new String();
			boolean status = true;
			String pinNumber =new String();
			String request = "";
			String chequeNum = new String();
			String chequeTemp = new String();
			while (status) {
				
				pinNumber = JOptionPane.showInputDialog(null,
						"Enter the Pin Number");
				if(pinNumber!=null)
				{
					pinTemp = validation.accountNoTextField(pinNumber);	
				}
				else
				{
					break;
				}
				
				if (pinTemp.length() == 0) {
					status = false;
				} else {
					JOptionPane.showMessageDialog(null,
							"Invalid Field pls Re-enter");
				}
			}
			status = true;
			if (radioText.equalsIgnoreCase("chqsts")
					|| radioText.equalsIgnoreCase("dchsts")
					|| radioText.equalsIgnoreCase("chgpin")) {
				while (status) {
					
					if (!radioText.equalsIgnoreCase("chgpin"))
						chequeNum = JOptionPane.showInputDialog(null,
								"Enter the Cheque Number");
					else
						chequeNum = JOptionPane.showInputDialog(null,
								"Enter the New Pin Number");
					if(chequeNum!=null)
					chequeTemp = validation.accountNoTextField(chequeNum);
					else
					break;
					if (chequeTemp.length() == 0) {
						status = false;
					} else {
						JOptionPane.showMessageDialog(null,
								"Invalid Field pls Re-enter");
					}
				}

			}
			
			if (chequeNum.equals(""))
				request = radioText + " " + pinNumber;
			else
				request = radioText + " " + pinNumber + " " + chequeNum;
			if(pinNumber!=null&&chequeNum!=null)
			{
				jTextAreaRequest.setText(request);
				clientRequest.smsRequest(request);	
			}
			
		}
		if (arg0.getSource() == jButtonSubscribe) {
			boolean status = true;
			String accountNum = new String();
			String pinTemp = new String();
			while (status) {

				accountNum = JOptionPane.showInputDialog(null,
						"Enter the Account Number");
				if (accountNum != null) {
					pinTemp = validation.accountNoTextField(accountNum);
				} else {
					break;
				}

				if (pinTemp.length() == 0) {
					status = false;
				} else {
					JOptionPane.showMessageDialog(null,
							"Invalid Field pls Re-enter");
				}
			}
			if (accountNum!=null) {
				String request = "sub" + " " + accountNum;
				jTextAreaRequest.setText(request);
				clientRequest.smsRequest(request);
			}

		}
		if (arg0.getSource() == jButtonUnsubscribe) {
			boolean status = true;
			String accountNum = new String();
			String pinTemp = new String();
			while (status) {
				
				accountNum = JOptionPane.showInputDialog(null,
						"Enter the Pin Number");
				if(accountNum!=null)
				pinTemp = validation.accountNoTextField(accountNum);
				else
				break;
				if (pinTemp.length() == 0) {
					status = false;
				} else {
					JOptionPane.showMessageDialog(null,
							"Invalid Field pls Re-enter");
				}
			}
			if(accountNum!=null)
			{
				String request = "unsub" + " " + accountNum;
				jTextAreaRequest.setText(request);
				clientRequest.smsRequest(request);	
			}
			
		}
		if (arg0.getSource() == jButton) {

			String billerName = "", accountNum = "", mobile = "", cusName = "";
			billerName = validation
					.NameValidationTextField(jTextFieldBillerName.getText());
			accountNum = validation
					.accountNoTextField(RegisterjTextFieldAccountNo.getText());
			mobile = validation
					.MobileNoTextField(RegisterjTextFieldMobileNumber.getText());
			cusName = validation.NameValidationTextField(jTextFieldCusName
					.getText());
			if (billerName.length() > 0) {

				JOptionPane.showMessageDialog(null, billerName);
				billerName = new String();
			} else if (accountNum.length() > 0) {

				JOptionPane.showMessageDialog(null, accountNum);
				accountNum = new String();
			} else if (mobile.length() > 0) {
				JOptionPane.showMessageDialog(null, mobile);
				mobile = new String();
			} else if (cusName.length() > 0) {
				JOptionPane.showMessageDialog(null, cusName);
				cusName = new String();
			} else {
				String request = "register "
						+ jComboBoxCity.getSelectedItem().toString() + " "
						+ jTextFieldBillerName.getText() + " "
						+ RegisterjTextFieldAccountNo.getText() + " "
						+ RegisterjTextFieldMobileNumber.getText() + " "
						+ jTextFieldCusName.getText();

				clientRequest.smsRequest(request);
			}
		}
		if (arg0.getSource() == jButtonTransfer) {
			String accountNumber = "", amount = "";
			accountNumber = validation.accountNoTextField(jTextFieldTos
					.getText());
			amount = validation.amountTextField(jTextFieldAmount.getText());
			if (accountNumber.length() > 0) {
				JOptionPane.showMessageDialog(null, accountNumber);
			} else if (amount.length() > 0) {
				JOptionPane.showMessageDialog(null, amount);
			} else {
				String request = "own " + jTextFieldTos.getText() + " "
						+ jTextFieldAmount.getText() + " "
						+ ClientRecv.accountNUmber;
				clientRequest.smsRequest(request);
			}
		}
		if (arg0.getSource() == paymentsJButton) {

			String accountNum = "", amount = "";
			accountNum = validation
					.accountNoTextField(paymentsaccountNoTextField.getText());
			amount = validation.amountTextField(paymentsAmountTextField
					.getText());
			if (accountNum.length() > 0) {
				JOptionPane.showMessageDialog(null, accountNum);
				accountNum = new String();
			} else if (amount.length() > 0) {
				JOptionPane.showMessageDialog(null, amount);
				amount = new String();
			} else {
				String request = "payment "
						+ paymentsaccountNoTextField.getText() + " "
						+ paymentsAmountTextField.getText() + " "
						+ jComboBox.getSelectedItem().toString() + " "
						+ ClientRecv.accountNUmber;
				clientRequest.smsRequest(request);
			}
		}
		if (arg0.getSource() == chequeJButton) {
			String accountNum = "", chqueNum = "", amount = "", date = "";
			accountNum = validation.accountNoTextField(chequeJTextFieldAccount
					.getText());
			chqueNum = validation.chequeNoTextField(chequejTextFieldChequeNum
					.getText());
			amount = validation.amountTextField(chequeJTextFieldAmount
					.getText());
			// date = validation.DateTextField(chequeJTextFieldDate.getText());
			if (accountNum.length() > 0) {
				JOptionPane.showMessageDialog(null, accountNum);
				accountNum = new String();
			} else if (chqueNum.length() > 0) {
				JOptionPane.showMessageDialog(null, chqueNum);
				chqueNum = new String();
			} else if (amount.length() > 0) {
				JOptionPane.showMessageDialog(null, amount);
				amount = new String();
			} else if (date.length() > 0) {
				JOptionPane.showMessageDialog(null, date);
				date = new String();
			} else {
				String request = "cheque" + " "
						+ chequeJTextFieldAccount.getText() + " "
						+ chequejTextFieldChequeNum.getText() + " "
						+ chequeJTextFieldAmount.getText() + " "
						+ ClientRecv.accountNUmber;
				clientRequest.smsRequest(request);
			}
		}
		if (arg0.getSource() == registerJButton) {
			String customerName = "", accountNum = "", emailAddress = "", password = "";
			customerName = validation.NameValidationTextField(regjTextFieldCus
					.getText());
			accountNum = validation.accountNoTextField(regjTextFieldAct
					.getText());
			emailAddress = validation
					.emailAddress(regjTextFieldEmail.getText());
			password = validation.NameValidationTextField(jpassWord.getText());
			if (customerName.length() > 0) {
				JOptionPane.showMessageDialog(null, customerName);
				customerName = new String();
			} else if (accountNum.length() > 0) {
				JOptionPane.showMessageDialog(null, accountNum);
				accountNum = new String();
			} else if (password.length() > 0) {
				JOptionPane.showMessageDialog(null, password);
				password = new String();
			} else if (emailAddress.length() > 0) {
				JOptionPane.showMessageDialog(null, emailAddress);
				emailAddress = new String();
			}

			else {
				Random random = new Random();
				RegistrationDatabase registrationDatabase = new RegistrationDatabase();
				String balance = String.valueOf(random.nextInt(10))
						+ String.valueOf(random.nextInt(10))
						+ String.valueOf(random.nextInt(10))
						+ String.valueOf(random.nextInt(10));
				RegistrationVO registrationVO = new RegistrationVO();
				registrationVO.setCustomerName(regjTextFieldCus.getText());
				registrationVO.setAccountNumber(regjTextFieldAct.getText());
				registrationVO.setEmailAddress(regjTextFieldEmail.getText());
				registrationVO.setBalance(balance);
				registrationVO.setPassword(jpassWord.getText());
				String result = registrationDatabase
						.Registration(registrationVO);
				// System.out.println(result);
				JOptionPane.showMessageDialog(null, result);

			}

		}
		if (arg0.getSource() == loginJbutton) {
			String userName = "";
			String passWord = "";
			String request = "";
			userName = validation.NameValidationTextField(loginUser.getText());
			passWord = validation.NameValidationTextField(loginPass.getText());
			if (userName.length() > 0) {
				JOptionPane.showMessageDialog(null, "Invalid UserName");
			} else if (passWord.length() > 0) {
				JOptionPane.showMessageDialog(null, "Invalid PassWord");
			} else {
				request = "login" + " " + loginUser.getText() + " "
						+ loginPass.getText();
				clientRequest.smsRequest(request);
			}
		}
		if (arg0.getSource() == jButtonSearch) {
			String accountNumber = "", amount = "", cheque1 = "", cheque2 = "";
			accountNumber = validation.accountNoTextField(jTextFieldSearchAct
					.getText());
			// /amount=validation.amountTextField(jTextFieldSearchAmt.getText());
			cheque1 = validation.accountNoTextField(jTextFieldChequeFrom
					.getText());
			cheque2 = validation.accountNoTextField(jTextFieldChequeTo
					.getText());
			if (accountNumber.length() > 0) {
				JOptionPane.showMessageDialog(null, accountNumber);
			} else if (cheque1.length() > 0) {
				JOptionPane.showMessageDialog(null, cheque1);
			} else if (cheque2.length() > 0) {
				JOptionPane.showMessageDialog(null, cheque2);
			} else {
				String request = "search " + jTextFieldSearchAct.getText()
						+ " " + jTextFieldChequeFrom.getText() + " "
						+ jTextFieldChequeTo.getText();
				clientRequest.smsRequest(request);
			}
		}

	}

}
